<?php
function getFiles($dir) {
	$array = array();
    if (is_dir($dir)) {
        if ($handle = opendir($dir)) {
            while (($file = readdir($handle)) !== false) {
                if ($file != "." && $file != ".." && $file != "Thumbs.db") { /*pesky windows, images..*/
                	array_push($array, $file);
                }
            }
            closedir($handle);
        }
    }
    return $array;
}
echo<<< EOQ
		  </table>
        </td>
      </tr>
      <tr><td colspan="2" align="center"><table border="0" width="100%"><tr>
EOQ;
	$images = getFiles("adverts/");
	for ($i = 1; $i <= 3; $i++) {
		shuffle($images);
		$file = array_pop($images);
		echo<<< EOQ
		<td><img src="adverts/$file" alt="Advert $i" border="0"></td>
EOQ;
	}
echo<<< EOQ
	</tr></table></td></tr>
    </table>
  </body>
</html>
EOQ;
?>